<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('信件工单-审定')"/>
    <link rel="stylesheet" type="text/css" th:href="@{/ajax/libs/qxEasyUI/themes/default/easyui.css}">
</head>
<style>
    .bootstrap-tagsinput > input {
        display: none;
    }
</style>

<body style="background-color: #F4F6FA">
<div id="admui-siteConTabs " class="main-content" style="margin: 0;padding: 0">

    <form id="form-user-add" class="form-horizontal" th:object="${mmailWorkForm}" style="background-color: #F4F6FA">
        <input type="hidden" name="pkId" id="pkId" th:value="${pkId}">
        <input type="hidden" name="originFK" id="originFK" th:value="${originFK}">
        <input type="hidden" name="crtStepId" id="txtCrtStepId">
        <input type="hidden" name="crtStepName" id="txtCrtStepName">
        <input type="hidden" name="opAct" id="opAct">
        <input type="hidden" name="sortCode" id="sortCode" th:value="${sortCode}">
        <div class="col-sm-12" style="display: flex">
            <!--     左       -->
            <div class="col-sm-6 entering-page">
                <!--   来电基本信息     -->
                <div class="col-sm-12 tltieBoder">
                    <div class="blueBorder"></div>
                    <h4 style="margin:0 0 0 10px">来电及通话信息</h4>
                </div>
                <!--事发地址-->
                <div class="form-group col-sm-12">
                    <label class="col-sm-2 control-label entering-pd">主题：</label>
                    <div class="col-sm-9">
                        <input name="fmAddress" th:field="*{fmAddress}" placeholder="请输入"
                               class="form-control workTheme" type="text"
                               required="">
                    </div>
                </div>
                <!-- 来电类型,内容类别..-->
                <div class="col-sm-12">
                    <div class="form-group col-sm-6">
                        <label class="col-sm-4 control-label  entering-pd">来电人：</label>
                        <div class="col-sm-8">
                            <input name="fromName" th:field="*{fromName}" placeholder="请输入"
                                   class="form-control scene " type="text">
                        </div>
                    </div>
                    <div class="form-group col-sm-6">
                        <label class="col-sm-4 control-label is-required entering-pd">联系电话：</label>
                        <div class="col-sm-8">
                            <input name="fromTel" th:field="*{fromTel}" placeholder="请输入"
                                   class="form-control scene theAddress" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-12 entering-mt">
                    <div class="form-group col-sm-6">
                        <label class="col-sm-4 control-label entering-pd">地区：</label>
                        <div class="col-sm-8">
                            <select name="fmAreaNo" th:field="*{fmAreaNo}" id="fmAreaNo"
                                    onchange="dropChgSendTextOnly(this,'fmAreaName');"
                                    th:with="district=${@commonServiceImpl.findArea()}" class="form-control formSelect"
                                    required>
                                <option value="">--请选择--</option>
                                <option th:each="item : ${district}" th:text="${item['CSText']}"
                                        th:value="${item['CSValue']}"></option>
                            </select>
                            <input type="hidden" id="fmAreaName" name="fmAreaName" th:value="*{fmAreaName}"/>
                        </div>
                    </div>
                    <div class="form-group col-sm-6">
                        <label class="col-sm-4 control-label entering-pd">来电类别：</label>
                        <div class="col-sm-8">
                            <select name="dfmClaNo" id="dfmClaNo"
                                    th:with="telTypes=${@commonServiceImpl.findTelType()}"
                                    onchange="dropChgSendTextOnly(this,'dfmClaName');"
                                    class="form-control formSelect">
                                <option value="">--请选择--</option>
                                <th:block th:each="item : ${telTypes}">
                                    <option th:text="${item['CSText']}" th:value="${item['CSValue']}"
                                            th:selected="${item['CSValue']} == *{dfmClaNo}"></option>
                                </th:block>
                            </select>
                            <input type="hidden" name="dfmClaName" id="dfmClaName" th:value="*{dfmClaName}"/>
                        </div>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-2 control-label entering-pd">流水号：</label>
                    <div class="col-sm-9">
                        <input name="wsCode" th:field="*{wsCode}" placeholder="请输入"
                               class="form-control workTheme" type="text"
                               disabled>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-2 control-label entering-pd">提取码：</label>
                    <div class="col-sm-9">
                        <input name="wsKey" th:field="*{wsKey}" placeholder="请输入"
                               class="form-control workTheme" type="text"
                               disabled>
                    </div>
                </div>
            </div>
            <!--     右       -->
            <div class="col-sm-6 entering-page">
                <div class="col-sm-12">
                    <!--   工单基本信息     -->
                    <div class="col-sm-12 tltieBoder">
                        <div class="blueBorder"></div>
                        <h4 style="margin:0 0 0 10px">信件内容整理</h4>
                    </div>
                    <div class="form-group col-sm-12">
                        <label class="col-sm-4 control-label entering-pd">信件来源：</label>
                        <div class="col-sm-6">
                            <input name="spareString" th:field="*{spareString}" placeholder="请输入"
                                   class="form-control workTheme" type="text"
                                   disabled>
                        </div>
                    </div>
                    <div class="form-group col-sm-12">
                        <label class="col-sm-2 control-label entering-pd">主题：</label>
                        <div class="col-sm-10">
                            <input name="fromTopic" th:field="*{fromTopic}" placeholder="请输入"
                                   class="form-control workTheme" type="text"
                                   required="">
                        </div>
                    </div>
                    <div class="col-sm-12" style="margin: 8px 0 8px 0;">
                        <div class="form-group">
                            <label class="col-xs-2 control-label entering-pd">内容：</label>
                            <div class="col-xs-10">
                                <!--呈批-->
                                <textarea name="fmContent" th:field="*{fmContent}" maxlength="3500"
                                          class="form-control workRemark"
                                          rows="3" style="height: 100px"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label entering-pd">同意公开：</label>
                            <div class="col-xs-8">
                                <label class="check-box">
                                    <input name="openFrom" th:checked="*{openFrom == 1}" value="1" type="radio">是
                                </label>
                                <label class="check-box">
                                    <input name="openFrom" th:checked="*{openFrom == 0}" value="0" type="radio">否
                                </label>
                            </div>
                        </div>
                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label entering-pd">提交时间：</label>
                            <div class="col-sm-8">
                                <input name="iptTime" th:field="*{iptTime}" placeholder="请输入"
                                       class="form-control code"
                                       type="text" disabled>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label entering-pd">来信类别：</label>
                            <div class="col-sm-8">
                                <select name="dfmClaNo" id="dfmClaN"
                                        th:with="telTypes=${@commonServiceImpl.findTelType()}"
                                        onchange="dropChgSendTextOnly(this,'dfmClaName');"
                                        class="form-control formSelect">
                                    <option value="">--请选择--</option>
                                    <th:block th:each="item : ${telTypes}">
                                        <option th:text="${item['CSText']}" th:value="${item['CSValue']}"
                                                th:selected="${item['CSValue']} == *{dfmClaNo}"></option>
                                    </th:block>
                                </select>
                                <input type="hidden" name="dfmClaName" id="dfmClaNam" th:value="*{dfmClaName}"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-6">
                            <label class="col-sm-4 control-label entering-pd">内容类别：</label>
                            <div class="col-sm-8">
                                <input id="qxCT" style="width:143px;height:31px;" th:value="*{dcntAName}">
                                <input id="txtDcntAcode" name="dcntACode" type="hidden" th:value="*{dcntACode}"/>
                                <input id="txtDCntAName" name="dcntAName" type="hidden" th:value="*{dcntAName}"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--内下-->
        <div class="col-sm-12 entering-page">
            <div class="col-sm-12 tltieBoder">
                <div class="blueBorder"></div>
                <h4 style="margin:0 0 0 10px">工单基本信息</h4>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label is-required entering-pd">工单编号：</label>
                    <div class="col-sm-8">
                        <input name="workFormNo" th:field="*{workFormNo}" placeholder="请输入"
                               class="form-control scene theAddress" type="text" disabled>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label is-required entering-pd">工单备注：</label>
                    <div class="col-sm-8">
                        <input name="wfRemark" th:field="*{wfRemark}" placeholder="请输入"
                               class="form-control scene theAddress" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label  entering-pd">工单性质：</label>
                    <div class="col-sm-8">
                        <select name="setProId" id="setProId" onchange="getSetProName()"
                                th:with="district=${@commonServiceImpl.findWorkFormType()}"
                                class="form-control formSelect">
                            <option value="">--请选择--</option>
                            <option th:each="item : ${district}" th:text="${item['CSText']}"
                                    th:value="${item['CSValue']}"
                                    th:selected="${item['CSValue']} == *{setProId}"></option>
                        </select>
                        <input id="setProName" type="hidden" name="setProName" th:value="*{setProName}"/>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label entering-pd">拟办时限：</label>
                    <div class="col-sm-8">
                        <input name="wfLimit" th:field="*{wfLimit}" placeholder="请输入"
                               class="form-control code"
                               type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label entering-pd">建议公开：</label>
                    <div class="col-xs-8">
                        <label class="check-box">
                            <input name="openX" th:checked="*{openX == 1}" value="1" type="radio">是
                        </label>
                        <label class="check-box">
                            <input name="openX" th:checked="*{openX == 0}" value="0" type="radio">否
                        </label>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label entering-pd">摘报：</label>
                    <div class="col-xs-8">
                        <label class="check-box">
                            <input name="reportFlag" th:checked="*{reportFlag == 1}" value="1" type="radio">是
                        </label>
                        <label class="check-box">
                            <input name="reportFlag" th:checked="*{reportFlag == 0}" value="0" type="radio">否
                        </label>
                    </div>
                </div>
            </div>
            <div class="col-sm-12">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label entering-pd">创建人：</label>
                    <div class="col-sm-8">
                        <input name="iptWorker" th:field="*{iptWorker}" placeholder="请输入"
                               class="form-control code"
                               type="text" disabled>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label entering-pd">创建时间：</label>
                    <div class="col-sm-8">
                        <input name="iptTime" th:field="*{iptTime}" placeholder="请输入"
                               class="form-control code"
                               type="text" disabled>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-12 entering-page">
            <!--   拟办部门     -->
            <div class="col-sm-12 tltieBoder">
                <div class="blueBorder"></div>
                <h4 style="margin:0 0 0 10px">拟办部门</h4>
            </div>
            <div class="col-sm-12 entering-page">
                <div class="btn-group-sm" id="toolbar" role="group">
                    <label class="control-label"> <a class="btn btn-success btn-sm" onclick="proposed()">
                        <i class="fa fa-plus"></i> 新增
                    </a></label>
                </div>
                <table id="bootstrap-table"></table>
            </div>
            <!--按钮-->
            <div class="col-sm-12 entering-bt" style="justify-content: center;">
                <button type="button" class="btn btn-sm btn-info" id="btnBack" onclick="btnSbmtClick(11)">通过并提交
                </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-sm btn-info" onclick="workFormOver()">直接答复
                </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-sm btn-danger" onclick="btnSbmtClick(-11)">作废
                </button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button type="button" class="btn btn-sm btn-warning" onclick="$.modal.closeTab()">关闭
                </button>&nbsp;
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<script th:src="@{/ajax/libs/qxEasyUI/jquery.easyui.min.js}"></script>
<script th:src="@{/js/sendDeptList.js}"></script>
<script th:src="@{/common/js/hm-ui.js}"></script>

<script>
    var prefix = ctx + "system/mMailWF";
    // 选择内容分类
    $('#qxCT').combotree({
        url: '/system/common/findContentCate',
        required: false,
        onSelect: function (record) {
            $("#txtDcntAcode").val(record.id);
            $("#txtDCntAName").val(record.text);
            var dfmClaName = $("#dfmClaNo option:selected").text();
            var fromName = $("#fromName").val();
            $("#wsTopic").val(fromName + '[' + dfmClaName + ']' + record.text);
        }
    });

    $('#dfmClaNo').change(function () {
        var dfmClaName = $("#dfmClaNo option:selected").text();
        var txtDCntAName = $("#txtDCntAName").val();
        var fromName = $("#fromName").val();
        $("#wsTopic").val(fromName + '[' + dfmClaName + ']' + txtDCntAName);
    })

    function getSetProName() {
        var proName = $("#setProId").find("option:selected").text();
        if (proName === '-请选择-') {
            $("#setProName").val("");
        } else {
            $("#setProName").val(proName);
        }
    }

    function proposed() {
        let pkId = $('#pkId').val();
        var url = prefix + "/rManage/sendDept/" + pkId + "?wfId=" + pkId;
        var width = '70%';
        var config = {
            id: 'deptdialog',
            title: '拟办部门',
            width: width,
            url: url,
            callBack: function (index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler();
            }
        };
        $.modal.openOptions(config);
    }

    function btnSbmtClick(opVal) {
        $('#opAct').val(opVal);
        var tmp = $("#setProId").val();
        switch (opVal.toString()) {
            case "11":
                if ("11" != tmp.toString()) {
                    $("#txtCrtStepId").val("200");
                    $("#txtCrtStepName").val("效能办领导审核");
                } else {//普通工单
                    $("#txtCrtStepId").val("400");
                    $("#txtCrtStepName").val("市级部门处理");
                }
                break;
            case "-11":
                $("#txtCrtStepId").val("-1");
                $("#txtCrtStepName").val("作废");
                break;
            default :
                break;
        }
        if ($.validate.form()) {
            let data = $('#form-user-add').serializeArray();
            $.operate.saveTab(prefix + "/rManage/wfDraftCheckJson", data);
        }
    }
    function workFormOver() {
        let bootstrapTable = $("#bootstrap-table").bootstrapTable('getData', false);
        if (bootstrapTable.length > 0) {
            $.modal.alertWarning("错误提示：请删除承办部门");
            return;
        }
        var url = prefix+"/rManage/mWFormOver/"+$('#pkId').val();
        $.modal.parentTab('直接答复工单',url);
    }
</script>
</body>
</html>

